package utils

import (
	"strings"

	"github.com/gin-gonic/gin"
)

// 获取用户真实IP
func GetRealIP(c *gin.Context) string {
	ip := c.Request.Header.Get("X-Real-IP")
	if ip == "" {
		ip = c.Request.Header.Get("X-Forwarded-For")
	}
	if ip == "" {
		ip = c.Request.RemoteAddr
	}
	ip = strings.Split(ip, ":")[0]
	return ip
}
